﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GameEngine.View.Components;
using MapEngine;
using GameEditor.View.Components;
using GameEngine.Model.Data;

namespace SilverlightClientEditor.View.Components
{
    public partial class LevelPropertiesEditorUC
        : UserControl, ILevelEditorMenuView<int>
    {
        //public event Action<Point> OnSizeChanged;
        public LevelPropertiesEditorUC()
        {
            InitializeComponent();
            //LayoutRoot.SizeChanged += MapContainer_LayoutUpdated;
            EditWorldButton.Tag = ILevelEditorMenuViewConstants.ButtonTags.EDITWORLD;
            NewWorldButton.Tag = ILevelEditorMenuViewConstants.ButtonTags.NEWWORLD;
            //RemoveWorldButton.Tag = ILevelEditorMenuViewConstants.ButtonTags.REMOVEWORLD;
            //CopyAsNewWorldButton.Tag = ILevelEditorMenuViewConstants.ButtonTags.COPYASNEWWORLD;
            //OkButton.Tag = ILevelEditorMenuViewConstants.ButtonTags.OK;
            //CancelButton.Tag = ILevelEditorMenuViewConstants.ButtonTags.CANCEL;
            EditWorldComboBox.DisplayMemberPath = "Value";
        }

        public string LevelName {
            get { return NameTextBox.Text; }
            set { NameTextBox.Text = value; }
        }

        public void AddWorld(IWorldVOId id) { 
            EditWorldComboBox.Items.Add(id);
            if (EditWorldComboBox.SelectedItem == null)
                EditWorldComboBox.SelectedItem = id;
        }
        public void RemoveWorld(IWorldVOId id) { EditWorldComboBox.Items.Remove(id); }
        public List<IWorldVOId> GetWorlds()
        {
            List<IWorldVOId> result = new List<IWorldVOId>();
            foreach (var obj in EditWorldComboBox.Items)
            {
                result.Add(obj as IWorldVOId);
            }
            return result;
        }
        public IWorldVOId SelectedWorld
        {
            get { return EditWorldComboBox.SelectedItem as IWorldVOId; }
        }

        public event OnButtonClickHandler<ILevelEditorMenuViewConstants.ButtonTags> OnExternalActionButtonClick;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //if (OnButtonClick != null)
            //    OnButtonClick((ILevelEditorMenuViewConstants.ButtonTags)((Button)sender).Tag);
        }
    }
}
